QuickOPC User's Guide and Reference
Create<TValue>(String,String,String,Int32,Single) Method
Example 



OpcLabs.EasyOpcClassic Assembly > OpcLabs.EasyOpc.DataAccess.Reactive Namespace > DAItemChangedObservable Class > Create Method : Create<TValue>(String,String,String,Int32,Single) Method
Name of the machine (empty string for local computer).
Contains ProgID of the OPC server.
ID of the item that will be subscribed to.
How often should the updates be received (number of milliseconds)
The percent change in an item value that will cause an update
Creates a new item change observable for OPC item, specifying machine name, server class, item ID, requested update rate, and percent deadband.
Syntax
'Declaration
 
<NotNullAttribute()>
Public Overloads Shared Function Create(Of TValue)( _
   ByVal machineName As String, _
   ByVal serverClass As String, _
   ByVal itemId As String, _
   ByVal requestedUpdateRate As Integer, _
   ByVal percentDeadband As Single _
) As DAItemChangedObservable(Of TValue)
'Usage
 
Dim machineName As String
Dim serverClass As String
Dim itemId As String
Dim requestedUpdateRate As Integer
Dim percentDeadband As Single
Dim value As DAItemChangedObservable(Of TValue)
 
value = DAItemChangedObservable.Create(Of TValue)(machineName, serverClass, itemId, requestedUpdateRate, percentDeadband)

Parameters

machineName
Name of the machine (empty string for local computer).
serverClass
Contains ProgID of the OPC server.
itemId
ID of the item that will be subscribed to.
requestedUpdateRate
How often should the updates be received (number of milliseconds)
percentDeadband
The percent change in an item value that will cause an update

Type Parameters

TValue

Return Value

Returns an observable for changes in the given OPC item.
Remarks
The DAReactive.DefaultClientSelector selector will be used for OPC Data Access operations.
Example

.NET

// Shows how to create an observable for OPC-DA item changes, and subscribe to it with percent deadband.

using System;
using System.Threading;
using OpcLabs.EasyOpc.DataAccess.Reactive;

namespace ReactiveDocExamples
{
    namespace _DAItemChangedObservable
    {
        partial class Subscribe
        {
            public static void PercentDeadband()
            {
                const float percentDeadband = 5.0f;
                Console.WriteLine($"Creating observable with {percentDeadband}% deadband...");
                DAItemChangedObservable<double> ramp = 
                    DAItemChangedObservable.Create<double>("", "OPCLabs.KitServer.2", "Simulation.Ramp 0:100 (10 s)", 
                        requestedUpdateRate:100, percentDeadband:percentDeadband);

                Console.WriteLine("Subscribing...");
                using (ramp.Subscribe(e => Console.WriteLine(
                    (e.Exception is null) ? e.Vtq.ToString() : e.Exception.GetBaseException().ToString())))
                {
                    Console.WriteLine("Waiting for 10 seconds...");
                    Thread.Sleep(10*1000);

                    Console.WriteLine("Unsubscribing...");
                }

                Console.WriteLine("Waiting for 2 seconds...");
                Thread.Sleep(2 * 1000);
            }
        }
    }
}
Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also